package vip.bblog.cunadmin.modules.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import vip.bblog.cunadmin.common.entity.PageResult;
import vip.bblog.cunadmin.modules.system.entity.Wxuser;
import vip.bblog.cunadmin.modules.system.entity.Wxuser;
import vip.bblog.cunadmin.modules.system.mapper.WxuserMapper;
import vip.bblog.cunadmin.modules.system.service.WxuserService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class WxuserServiceImpl extends ServiceImpl<WxuserMapper, Wxuser> implements WxuserService {

    @Autowired
    private WxuserMapper wxuserMapper;

    /**
     * 分页查询
     *
     * @param params 参数
     * @return R
     */
    @Override
    public Map<String, Object> getByPage(Wxuser params){
        int page = (params.getPage() -1) * params.getSize();
        params.setPage(page);
        List<Wxuser> list = wxuserMapper.getByPage(params);
        Map<String, Object> map = new HashMap<>();
        map.put("total",wxuserMapper.getTotal(params));
        map.put("records",list);
        return map;
    }

    @Override
    public Wxuser getUserByOpenid(@Param("openid")String openid){
        return wxuserMapper.getUserByOpenid(openid);
    }
}
